package Bao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
public class Glxg{
    public boolean addGl(Gl gl)throws Exception{
        Connection conn=Lj.getConntion();
        Statement stmt=conn.createStatement();
        String sqlString="insert into cf values('"+gl.getId()+"','"+gl.getName()+"')";
        return stmt.executeUpdate(sqlString)>0;
    }
    public boolean delGl(Gl gl)throws Exception{
        Connection conn=Lj.getConntion();
        Statement stmt=conn.createStatement();
        String sqlString="delete table cf where id='"+gl.getId()+"'";
        return stmt.executeUpdate(sqlString)>0;
    }
    public boolean updataGl(Gl gl)throws Exception{
        Connection conn=Lj.getConntion();
        Statement stmt=conn.createStatement();
        String sqlString="update table cf set id='"+gl.getId()+"'";
        return stmt.executeUpdate(sqlString)>0;
    }
    public ArrayList<Gl> listAllGl()throws Exception{
        Connection conn=Lj.getConntion();
        Statement stmt=conn.createStatement();
        ResultSet rs=stmt.executeQuery("select * from cf");
        ArrayList<Gl> gl=new ArrayList<Gl>();
        while (rs.next()){
            Gl gh=new Gl();
            gh.setId(rs.getNString("id"));
            gh.setName(rs.getNString("name"));
            gl.add(gh);
        }
        return gl;
    }
}
